package cn.softgame.jserver.connector.data;

import java.io.InputStream;
import java.io.OutputStream;

import cn.softgame.jserver.queue.MessageQueue;

/**
 * 一个访问者具体子类
 * @author xuquan
 * 日期:2013-5-28
 */
public class QueueTakeWorker implements QueueWorker{
	private MessageQueue messageQueue=null;

	public QueueTakeWorker(MessageQueue messageQueue) {
		this.messageQueue=messageQueue;
	}

	@Override
	public void run(int msgType, Linkable object) throws Exception {
		InputStream is = null;
		if(msgType==REQUEST){
			is = (InputStream) messageQueue.removeReqFirst();
		}else if(msgType==RESPONSE){
			is = (InputStream) messageQueue.removeRespFirst();
		}
		
		object.setInputStream(is);
		is.close();
	}

}
